package com.mojo.pojo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import java.util.StringJoiner;

/**
 * @author <a href="mailto:sjj@jianzhimao.com">mojo</a>
 * copyright (C), 2013-2022, 广州九尾信息科技有限公司
 * @date 2022/3/2 15:12
 */
public class Animal {
    @Value("动物")
    private String name;
    @Value("1")
    private int type;
    private Student student;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public Student getStudent() {
        return student;
    }

    //实现与xml中配置Property一样的注入效果
    @Autowired
    public void setStudent(Student student) {
        this.student = student;
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", Animal.class.getSimpleName() + "[", "]")
                .add("name='" + name + "'")
                .add("type=" + type)
                .add("student=" + student)
                .toString();
    }
}
